Foreshadowing

  • What are splines anyway?
  • What good are splines for modeling?
  • What did I learn about RSV?

Splines

Splines: A brief history

Splines: Math

A spline is a piecewise polynomial function on \([a, b] \subset \mathbb{R}\). The points \(t_0, t_1, \dots, t_n\) at which the polynomial segments are joined are called knots.

\[ S(x) = \begin{cases} P_0(x): t \in [t_0, t_1) \\ P_1(x): t \in [t_1, t_2) \\ \cdots \\ P_{n-1}(x): t \in [t_{n-1}, t_n] \end{cases} \]

If \(P_i\) are polynomials of degree ≤ m, then the spline S has degree m and order m+1.

A spline is continuous in all derivatives everywhere except at its knots. At its knots a spline can have continuity order ranging from -1 (no continuity) through m-1.

Spline #1: degree = 1, continuity = 0

Spline #2: degree = 1, continuity = -1

Spline #3: degree = 2, continuity = -1

Spline #4: degree = 2, continuity = 0

Spline #5: degree = 2, continuity = 1

Basis splines: Math

Splines most common in practical use are those with degree m and continuity order m-1.

For a given knot vector \(\vec{t} = (t_0, \dots t_n)\), and a given spline degree m, there exists a unique set of splines (basis splines) meeting the following criteria:

  • Locality: Basis spline \(B_i\) is zero outside of the segment \([t_i, t_{i+n}]\)
  • Scaling: \(\sum B_i(x) = 1, \forall x \in [t_m, t_{n-m}]\)

Basis splines #1: degree = 1

Basis splines #2: degree = 2

Basis splines: Importance

All splines of degree m and continuity order m-1 over the knot vector \(\vec t\) can be expressed as a linear combination of basis splines.

Think of basis splines as blending functions that provide smooth transitions between fixed control points.

Control points shape the spline.

Blending #1: Color (degree = 1)

Blending #2: Position (degree = 1)

Blending #3: Position (degree = 2)

Basis spline modeling

B-Spline Modeling: The Basics

Control points shape the spline. In a spline model, model parameters are (related to) control points.

In simple a simple B-spline model, quality of fit is measured by mean square error (MSE).

B-Spline Model #1

B-Spline Model #2

B-Spline Model #2

B-spline Modeling: Overfitting and Penalties

B-spline fitting with MSE is sensitive to number of knots. Too many knots lead to overfitting.

One solution to this problem is to include smoothness in measure of fit; this is known as “penalty”.

Most common penalty is integral of second derivative squared, also knows as 2nd order penalty.

B-spline used for fitting with a penalty term are known as penalized B-splines, or P-splines.

B-Spline Model #3

B-Spline Modeling: Cyclic Time

B-splines make no smoothness guarantee at the beginning and end of a cyclic time period.

B-Spline Modeling: Cyclic Time

That is what cyclic B-splines are used for